package com.groupnections.client.Entities;

import java.util.List;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.groupnections.client.GlobalVariables;
import com.groupnections.shared.Entity;

public class ListEntities {

	public ListEntities() {

		final EntitiesDatabaseServerCallsAsync databaseServerCalls = GWT
				.create(EntitiesDatabaseServerCalls.class);

		databaseServerCalls.listEntities(new AsyncCallback<List<Entity>>() {

			public void onSuccess(List<Entity> entities) {

				if (entities != null && entities.size() > 0) {

					for (Entity entity : entities) {

						GlobalVariables.entitiesMap.put(entity.getEntityID(),
								entity);
					}

					new InitializeEntity(GlobalVariables.entitiesMap
							.get("AllineO"));
				}
			}

			public void onFailure(Throwable caught) {
				// Show the RPC error message to the user

			}

		});

	}

}
